//
//  ViewController.m
//  01 Touch
//
//  Created by DengYi on 15/3/16.
//  Copyright (c) 2015年 www.iphonetrain.com无限互联3G学院. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    
    // 默认view 交互 是YES。 imageView 默认关闭 NO
    self.view.userInteractionEnabled = YES;
    
    // mor NO
    self.view.multipleTouchEnabled = YES;
    
    // 如果父视图的交互关闭，会影响到子视图
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(60, 100, 200, 35);
    [button setTitle:@"action" forState:UIControlStateNormal];
    [self.view addSubview:button];
    
}

// 覆写父类的方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"开始触摸 ： %ld", touches.count);
    // 获取touch对象
    UITouch *touch = [touches anyObject];
//    NSLog(@"touch : %@", touch);
    
//    NSLog(@"阶段 : %ld", [touch phase]);
    
//    NSLog(@"widow : %@" ,[touch window]);
    
    // 获取点击次数
    NSUInteger tapCount = [touch tapCount];
    NSLog(@"点击次数 : %lu", tapCount);
    
    // 获取触摸点所在的位置
    CGPoint location = [touch locationInView:self.view];
    NSLog(@"loaction : %@", NSStringFromCGPoint(location));
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
//    NSLog(@"触摸移动");
    
    // 获取touch对象
    UITouch *touch = [touches anyObject];
    
    // 获取触摸点所在的位置
    CGPoint location = [touch locationInView:self.view];
    NSLog(@"loaction : %@", NSStringFromCGPoint(location));
    
    
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
//    NSLog(@"触摸结束");
    
}

// 触摸被取消，一定是在触摸事件执行时，才有取消的条件（比如电话）
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"触摸取消");
}




@end
